package com.power.using.mybomb.adapter;

import android.content.Context;
import android.view.View;

import com.power.using.mybomb.R;
import com.power.using.mybomb.adapter.base.BaseRecyclerAdapter;
import com.power.using.mybomb.adapter.base.BaseRecyclerHolder;
import com.power.using.mybomb.bean.Friend;
import com.power.using.mybomb.bean.User;
import com.power.using.mybomb.db.NewFriendManager;

import java.util.Collection;

/**
 * Created by 聪明一只哈 on 2020/3/23.
 * Time: 2020/3/23  9:25
 */
public class ContactAdapter extends BaseRecyclerAdapter<Friend> {

    public static final int TYPE_NEWFRIEND=0;
    public static final int TYPE_ITEM=1;


    public ContactAdapter(Context context, Collection<Friend> datas, IMutlipleItem<Friend> items) {
        super(context, datas, items);
    }

    @Override
    public void bindView(BaseRecyclerHolder holder, Friend friend, int position) {

        if(holder.layoutId== R.layout.item_contact){

            User user = friend.getFriendUser();

            holder.setImageView(user==null?null:user.getAvatar(),R.mipmap.head,R.id.iv_recent_avatar);
            holder.setText(R.id.tv_recent_name,user==null?"未知":""+user.getUsername());
        }else if(holder.layoutId==R.layout.header_new_friend){

            if(NewFriendManager.getInstance(context).hasNewFriendInvitation()){
                holder.setVisible(R.id.iv_msg_tips, View.VISIBLE);
            }else{
                holder.setVisible(R.id.iv_msg_tips,View.GONE);
            }

        }





    }
}
